import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    name:'未登录游客'
  },
  getters: {
  },
  //同步，修改共享数据，并且是同步
  mutations: {
    setName (state, name) {
      state.name = name
    }
  },
  //通过actions调用mutations,actions可以实现异步操作。
  actions: {
    setNameByAxios(){
      axios({
        url: '/api/admin/employee/login',
        method: 'post',
        data: {
          username: 'admin',
          password: '123456',
        }

      })
    }
  },
  modules: {
  }
})
